package GUIAdapter;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.table.AbstractTableModel;
import ModelLayer.ResponseList;
import CTRLayer.RegistrationSchemaCTR;
import GUILayer.*;

	@SuppressWarnings("serial")
	public class TrainingModel extends AbstractTableModel
	{
		private final String[] columnHeader= {"Nr", "Opgave", "Respons", "MK", "Int", "Mest", "IntroSig", "MestSig", "Reg", "R", "P", "F"};
		
		private List<ResponseList> responseListList;

		public TrainingModel(List<ResponseList> responseListList)
		{
			this.responseListList = responseListList;
		}
		
		@Override
		public String getColumnName(int column)
		{
			// TODO Auto-generated method stub
			return columnHeader[column];
		}

		@Override
		public int getColumnCount()
		{
			// TODO Auto-generated method stub
			return columnHeader.length; //depends on amount of getters for a supplier eg.: "getName()"... very ugly
		}

		@Override
		public int getRowCount()
		{
			// TODO Auto-generated method stub
			return responseListList.size();
		}

		@Override
		public Object getValueAt(int row, int col)
		{
			// TODO Auto-generated method stub
			JButton button1 = new JButton("Reg.");
			final ResponseList responseList = responseListList.get(row);
			button1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) 
				{	
					new RegistrationSchema(responseList.getMasterCriterias(), responseList.getResponseListID());
				}
			});
			
			switch(col)
			{
			case 0:
				return responseList.getNumber();
			case 1:
				return responseList.getAssignment();
			case 2:
				return responseList.getResponse();
			case 3:
				return responseList.getMasterCriterias();
			case 4:
				return responseList.getIntroduced();
			case 5:
				return responseList.getMastered();
			case 6:
				return responseList.getIntroSignature();
			case 7:
				return responseList.getMastSignature();
			case 8:
				return button1;
			case 9:
				return "33%";
			case 10:
				return "33%";
			case 11:
				return "33%";
			}
			return null; //should never reach here..!
		}
		
		public int getindex()
		{
			int i = 0;
			for(int index = 0; responseListList.size() < index; index++)
			{
				i = index;
			}
			return i;
		}
	} //end TableSupplierAdapter